import {submitFormData, submitJsonData, submitMultipartFormData} from "../../../../../../redare/utils/Request";

/**
 * Created by RdevPlugins.JsPresenterBuilderAction on 2020-03-07 13:02:40.
 */

/**
 * @param body: {key, platform, id, enabled, incDel}
 * @param query: {curPage,pageSize}
 * @returns Promise
 */
export function findPlatformPage(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/page',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {key, platform, id, enabled, incDel}
 * @param query: {returnAll,curPage,pageSize}
 * @returns Promise
 */
export function findPlatformList(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/list',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, enabled, incDel}
 * @param query: {}
 * @returns Promise
 */
export function getPlatform(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/detail',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, key, defaults, enabled}
 * @param query: {curPage,pageSize}
 * @returns Promise
 */
export function findMenuPage(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/menu/page',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, key, defaults, enabled}
 * @param query: {returnAll,curPage,pageSize}
 * @returns Promise
 */
export function findMenuList(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/menu/list',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, enabled}
 * @param query: {}
 * @returns Promise
 */
export function getMenu(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/menu/detail',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, userPlatform, type, key, code, admin, defaults, platformUnionUserPlatform}
 * @param query: {curPage,pageSize}
 * @returns Promise
 */
export function findRolePage(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/role/page',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, userPlatform, type, key, code, admin, defaults, platformUnionUserPlatform}
 * @param query: {returnAll,curPage,pageSize}
 * @returns Promise
 */
export function findRoleList(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/role/list',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, type, userPlatform, code}
 * @param query: {}
 * @returns Promise
 */
export function getRole(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/role/detail',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {platform, userPlatform, name, code, des}
 * @param query: {}
 * @returns Promise
 */
export function addRole(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/role/add',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, userPlatform, name, code, des}
 * @param query: {}
 * @returns Promise
 */
export function modifyRole(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/role/modify',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

/**
 * @param body: {id, platform, userPlatform}
 * @param query: {}
 * @returns Promise
 */
export function delRole(body, query) {

    return new Promise((resolve, reject) => {

        submitJsonData({
            url: '/api/_webplatform_workbench/platform/role/del',
            bodyParams: body,
            urlParams: query
        }).then(
            result => {
                resolve(result);
            },
            error => reject(error)
        );
    });
}

